<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableWeChatPay extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('we_chat_pays', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('type');
            $table->string('user_id')->index();
            $table->string('appid', 32)->nullable();
            $table->string('mch_id', 32)->nullable();
            $table->string('device_info', 32)->nullable();
            $table->string('nonce_str', 32)->nullable();
            $table->string('sign', 32)->nullable();
            $table->string('sign_type', 32)->nullable();
            $table->string('body', 128)->nullable();
            $table->string('detail', 6000)->nullable();
            $table->string('attach', 127)->nullable();
            $table->string('out_trade_no', 32)->index();
            $table->string('fee_type', 16)->nullable();
            $table->integer('total_fee');
            $table->string('spbill_create_ip', 64)->nullable();
            $table->string('time_start', 14)->nullable();
            $table->string('time_expire', 14)->nullable();
            $table->string('trade_type', 16)->nullable();
            $table->string('openid', 128)->nullable();
            $table->string('prepay_id', 64)->nullable();

            $table->boolean('notified')->default(false);
            $table->string('transaction_id', 32)->nullable();
            $table->string('result_code', 16)->nullable();
            $table->string('err_code', 32)->nullable();
            $table->string('err_code_des', 128)->nullable();
            $table->string('is_subscribe', 1)->nullable();
            $table->string('bank_type', 16)->nullable();
            $table->string('time_end', 14)->nullable();

            $table->integer('refund_fee')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('we_chat_pays');
    }
}
